package com.eascs.web.o2o.web.reward.service.impl;

import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.common.util.StringUtil;
import com.eascs.site.view.BaseRestResult;
import com.eascs.web.o2o.web.reward.dao.BaseDao;
import com.eascs.web.o2o.web.reward.entity.DmRewardCurOverdueAmount;
import com.eascs.web.o2o.web.reward.entity.DmRewardReceiveOverdueAmount;
import com.eascs.web.o2o.web.reward.entity.DwRewardOverdue;
import com.eascs.web.o2o.web.reward.entity.OverdualForm;
import com.eascs.web.o2o.web.reward.entity.ReceivedPaymentsDetail;
import com.eascs.web.o2o.web.reward.service.OverdualReportService;
import com.eascs.web.sso.User;
import com.eascs.web.sso.UserHolder;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.inject.Inject;

@Service
public class OverdualReportServiceImpl implements OverdualReportService {
	
	private static Logger log = LoggerFactory.getLogger(OverdualReportServiceImpl.class);

	@Inject
	BaseDao baseDao;
	
	
	

	// 根据平台查询逾期报表
	@Override
	public PageResult<Object[]> getOverdualReportDetail(OverdualForm entity) {
		
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.getOverdualReportDetail")); 
		
		querySql.append(" AND t.t_month = ?");
		sqlPageQuery.addParam(entity.getMonth());
		
		if(!StringUtil.isEmpty(entity.getLoanStatus())){
			querySql.append(" AND t.overdue_type = ?");
			sqlPageQuery.addParam(entity.getLoanStatus());
		}
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND t.overdue_time >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND t.overdue_time <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}

	
	
	@Override
	public PageResult<Object[]> downOverdualReportDetail(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.downOverdualReportDetail")); 
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}
	
	
	
	@Override
	@Transactional("transactionManagerDbForReward")
	public BaseRestResult<String> addList(List<List<Object>> result){
			BaseRestResult<String> results = BaseRestResult.info("导入成功").andRefresh();
			User user=UserHolder.getUser();
			//删除当前月份前一个月的所有数据
			baseDao.executeSql(" delete from dw_reward_overdue where  t_month = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 month),'%Y-%m')");
			//将excel中的数据导入到数据库中
			if(result!=null&&result.size()>0){
				for (int i = 0; i < result.size(); i++) {
					@SuppressWarnings({ "unchecked", "rawtypes" })
					List<Object> list = (List) result.get(i);
					DwRewardOverdue overdueReportPO = new DwRewardOverdue();
					overdueReportPO.setT_month(list.get(0).toString());
					overdueReportPO.setProvince_name(list.get(1).toString());
					overdueReportPO.setProvince_code(list.get(2).toString());
					overdueReportPO.setLtd(list.get(3).toString());
					overdueReportPO.setLtd_code(list.get(4).toString());
					overdueReportPO.setLtd_name(list.get(5).toString());
					overdueReportPO.setBill_code(list.get(6).toString());
					overdueReportPO.setLoaner_name(list.get(7)==null?null:list.get(7).toString());
					overdueReportPO.setUser_name(list.get(8).toString());
					overdueReportPO.setUser_no(list.get(9).toString());
					overdueReportPO.setLoan_amount((BigDecimal)list.get(10));
				    overdueReportPO.setLoan_term(Integer.valueOf(list.get(11).toString()));
					overdueReportPO.setLoan_date((Date)list.get(12));
					overdueReportPO.setOverdue_time((Date)list.get(13));
					overdueReportPO.setOverdue_principal((BigDecimal)list.get(14));
					overdueReportPO.setOverdue_interest((BigDecimal)list.get(15));
					overdueReportPO.setOverdue_type(list.get(16).toString());
					overdueReportPO.setLate_charge((BigDecimal)list.get(17));
					overdueReportPO.setTotal_overdue((BigDecimal)list.get(18));
					overdueReportPO.setIs_lock("N");
					overdueReportPO.setCreate_user(user.getCname());
					overdueReportPO.setCreate_date(new Date());
					overdueReportPO.setUpdate_user(user.getCname());
					overdueReportPO.setUpdate_date(new Date());
					overdueReportPO.setConfirm_user(user.getCname());
					overdueReportPO.setConfirm_date(new Date());
					baseDao.saveEntity(overdueReportPO);
				}
			}else{
				log.error("导入的数据为空，事务回滚");
				throw new RuntimeException("导入的数据为空，请重新导入！");
			}
		   return results;
	}







	
	

	// 根据平台查询逾期报表
	@Override
	public PageResult<Object[]> getReceivedPaymentsDetail(OverdualForm entity) {
		
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.getReceivedPaymentsDetail")); 
		
		querySql.append(" AND t.t_month = ?");
		sqlPageQuery.addParam(entity.getMonth());
		
		
		if(!StringUtil.isEmpty(entity.getLoanStatus())){
			querySql.append(" AND t.type_of_return = ?");
			sqlPageQuery.addParam(entity.getLoanStatus());
		}
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND t.this_payment_date >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND t.this_payment_date <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}

	
	
	@Override
	public PageResult<Object[]> downReceivedPaymentsDetail(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.downReceivedPaymentsDetail")); 
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}
	
	
	
	@Override
	@Transactional("transactionManagerDbForReward")
	public BaseRestResult<String> addListByReceivedPaymentsDetail(List<List<Object>> result){
			BaseRestResult<String> results = BaseRestResult.info("导入成功").andRefresh();
			User user=UserHolder.getUser();
			//删除当前月份前一个月的所有数据
			baseDao.executeSql(" delete from dw_reward_received_payments where  t_month = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 month),'%Y-%m')");
			//将excel中的数据导入到数据库中
			if(result!=null&&result.size()>0){
				for (int i = 0; i < result.size(); i++) {
					@SuppressWarnings({ "unchecked", "rawtypes" })
					List<Object> list = (List) result.get(i);
					ReceivedPaymentsDetail receivedPaymentsDetail = new ReceivedPaymentsDetail();
					receivedPaymentsDetail.setT_month(list.get(0).toString());
					receivedPaymentsDetail.setProvince_name(list.get(1)==null?null:list.get(1).toString());
					receivedPaymentsDetail.setProvince_code(list.get(2)==null?null:list.get(2).toString());
					receivedPaymentsDetail.setLtd(list.get(3)==null?null:list.get(3).toString());
					receivedPaymentsDetail.setLtd_code(list.get(4)==null?null:list.get(4).toString());
					receivedPaymentsDetail.setLtd_name(list.get(5)==null?null:list.get(5).toString());
					receivedPaymentsDetail.setBill_code(list.get(6)==null?null:list.get(6).toString());
					receivedPaymentsDetail.setLoaner_name(list.get(7)==null?null:list.get(7).toString());
					receivedPaymentsDetail.setUser_name(list.get(8)==null?null:list.get(8).toString());
					receivedPaymentsDetail.setUser_no(list.get(9)==null?null:list.get(9).toString());
					receivedPaymentsDetail.setLoan_amount((BigDecimal)list.get(10));
					receivedPaymentsDetail.setLoan_term(list.get(11)==null?0:Integer.valueOf(list.get(11).toString()));
					receivedPaymentsDetail.setLoan_date((Date)list.get(12));
					receivedPaymentsDetail.setOverdue_start_time((Date)list.get(13));
					receivedPaymentsDetail.setThis_payment_capital((BigDecimal)list.get(14));
					receivedPaymentsDetail.setThis_payment_date((Date)list.get(15));
					receivedPaymentsDetail.setCollector(list.get(16)==null?null:list.get(16).toString());
					receivedPaymentsDetail.setRecovery_coefficient((BigDecimal)list.get(17));
					receivedPaymentsDetail.setType_of_return(list.get(18)==null?null:list.get(18).toString());
					receivedPaymentsDetail.setIs_lock("N");
					receivedPaymentsDetail.setCreate_user(user.getCname());
					receivedPaymentsDetail.setCreate_date(new Date());
					receivedPaymentsDetail.setUpdate_user(user.getCname());
					receivedPaymentsDetail.setUpdate_date(new Date());
					receivedPaymentsDetail.setConfirm_user(user.getCname());
					receivedPaymentsDetail.setConfirm_date(new Date());
					baseDao.saveEntity(receivedPaymentsDetail);
				}
			}else{
				log.error("导入的数据为空，事务回滚");
				throw new RuntimeException("导入的数据为空，请重新导入！");
			}
		   return results;
	}
	
	

	//当期逾期本息金额报表
	@Override
	public PageResult<Object[]> getReceiveOverdueAmount(OverdualForm entity) {
		
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.getReceiveOverdueAmount")); 
		
		querySql.append(" AND t.t_month = ?");
		sqlPageQuery.addParam(entity.getMonth());
		
		if(!StringUtil.isEmpty(entity.getLoanStatus())){
			querySql.append(" AND t.receive_type = ?");
			sqlPageQuery.addParam(entity.getLoanStatus());
		}
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND t.receive_date >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND t.receive_date <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}

	
	
	@Override
	public PageResult<Object[]> downReceiveOverdueAmount(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.downReceiveOverdueAmount")); 
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}
	
	
	
	@Override
	@Transactional("transactionManagerDbForReward")
	public BaseRestResult<String> addListByReceiveOverdueAmount(List<List<Object>> result){
			BaseRestResult<String> results = BaseRestResult.info("导入成功").andRefresh();
			User user=UserHolder.getUser();
			//删除当前月份前一个月的所有数据
			baseDao.executeSql(" delete from dm_reward_receive_overdue_amount where  t_month = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 month),'%Y-%m')");
			//将excel中的数据导入到数据库中
			if(result!=null&&result.size()>0){
				for (int i = 0; i < result.size(); i++) {
					@SuppressWarnings({ "unchecked", "rawtypes" })
					List<Object> list = (List) result.get(i);
					DmRewardReceiveOverdueAmount overdueReportPO = new DmRewardReceiveOverdueAmount();
					overdueReportPO.setT_month(list.get(0)==null?null:list.get(0).toString());
					overdueReportPO.setProvince_code(list.get(1)==null?null:list.get(1).toString());
					overdueReportPO.setProvince_name(list.get(2)==null?null:list.get(2).toString());
					overdueReportPO.setUser_no(list.get(3)==null?null:list.get(3).toString());
					overdueReportPO.setUser_code(list.get(4)==null?null:list.get(4).toString());
					overdueReportPO.setUser_name(list.get(5)==null?null:list.get(5).toString());
					overdueReportPO.setBill_code(list.get(6)==null?null:list.get(6).toString());
					overdueReportPO.setLoaner_name(list.get(7)==null?null:list.get(7).toString());
					overdueReportPO.setLoan_amount((BigDecimal)list.get(8));
					overdueReportPO.setLoan_term(list.get(9)==null?0:Integer.valueOf(list.get(9).toString()));
					overdueReportPO.setConvert_loan_amount((BigDecimal)list.get(10));
					overdueReportPO.setLoan_date((Date)list.get(11));
					overdueReportPO.setExpire_date((Date)list.get(12));
					overdueReportPO.setLtd(list.get(13)==null?null:list.get(13).toString());
					overdueReportPO.setLtd_code(list.get(14)==null?null:list.get(14).toString());
					overdueReportPO.setLtd_name(list.get(15)==null?null:list.get(15).toString());
					overdueReportPO.setReceive_amount((BigDecimal)list.get(16));
					overdueReportPO.setReceive_date((Date)list.get(17));
					overdueReportPO.setCollect_user(list.get(18)==null?null:list.get(18).toString());
					overdueReportPO.setCollect_coefficient((BigDecimal)list.get(19));
					overdueReportPO.setReceive_type(list.get(20)==null?null:list.get(20).toString());
					overdueReportPO.setUser_bill_relation(list.get(21)==null?null:list.get(21).toString());
					overdueReportPO.setIs_lock("N");
					overdueReportPO.setCreate_user(user.getCname());
					overdueReportPO.setCreate_date(new Date());
					overdueReportPO.setUpdate_user(user.getCname());
					overdueReportPO.setUpdate_date(new Date());
					overdueReportPO.setConfirm_user(user.getCname());
					overdueReportPO.setConfirm_date(new Date());
					baseDao.saveEntity(overdueReportPO);
				}
			}else{
				log.error("导入的数据为空，事务回滚");
				throw new RuntimeException("导入的数据为空，请重新导入！");
			}
		   return results;
	}


     //当期逾期本息金额报表
	@Override
	public PageResult<Object[]> getCurOverdueAmount(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.getCurOverdueAmount")); 
		
		querySql.append(" AND t.t_month = ?");
		sqlPageQuery.addParam(entity.getMonth());
		
		if(!StringUtil.isEmpty(entity.getLoanStatus())){
			querySql.append(" AND t.overdue_type = ?");
			sqlPageQuery.addParam(entity.getLoanStatus());
		}
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND t.overdue_date >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND t.overdue_date <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}



	@Override
	public PageResult<Object[]> downCurOverdueAmount(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.downCurOverdueAmount")); 
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}



	@Override
	public BaseRestResult<String> addListByCurOverdueAmount(List<List<Object>> result) {
		BaseRestResult<String> results = BaseRestResult.info("导入成功").andRefresh();
		User user=UserHolder.getUser();
		//删除当前月份前一个月的所有数据
		baseDao.executeSql(" delete from dm_reward_cur_overdue_amount where  t_month = DATE_FORMAT(DATE_SUB(now(),INTERVAL 1 month),'%Y-%m')");
		//将excel中的数据导入到数据库中
		if(result!=null&&result.size()>0){
			for (int i = 0; i < result.size(); i++) {
				@SuppressWarnings({ "unchecked", "rawtypes" })
				List<Object> list = (List) result.get(i);
				DmRewardCurOverdueAmount overdueReportPO = new DmRewardCurOverdueAmount();
				overdueReportPO.setT_month(list.get(0)==null?null:list.get(0).toString());
				overdueReportPO.setProvince_code(list.get(1)==null?null:list.get(1).toString());
				overdueReportPO.setProvince_name(list.get(2)==null?null:list.get(2).toString());
				overdueReportPO.setUser_no(list.get(3)==null?null:list.get(3).toString());
				overdueReportPO.setUser_code(list.get(4)==null?null:list.get(4).toString());
				overdueReportPO.setUser_name(list.get(5)==null?null:list.get(5).toString());
				overdueReportPO.setBill_code(list.get(6)==null?null:list.get(6).toString());
				overdueReportPO.setLoaner_name(list.get(7)==null?null:list.get(7).toString());
				overdueReportPO.setLoan_amount((BigDecimal)list.get(8));
				overdueReportPO.setLoan_term(list.get(0)==null?0:Integer.valueOf(list.get(9).toString()));
				overdueReportPO.setConvert_loan_amount((BigDecimal)list.get(10));
				overdueReportPO.setLoan_date((Date)list.get(11));
				overdueReportPO.setExpire_date((Date)list.get(12));
				overdueReportPO.setLtd(list.get(13)==null?null:list.get(13).toString());
				overdueReportPO.setLtd_code(list.get(14)==null?null:list.get(14).toString());
				overdueReportPO.setLtd_name(list.get(15)==null?null:list.get(15).toString());
				overdueReportPO.setOverdue_date((Date)list.get(16));
				overdueReportPO.setOverdue_principal((BigDecimal)list.get(17));
				overdueReportPO.setOverdue_interest((BigDecimal)list.get(18));
				overdueReportPO.setOverdue_penalty_interest((BigDecimal)list.get(19));
				overdueReportPO.setOverdue_total_amount((BigDecimal)list.get(20));
				overdueReportPO.setOverdue_type(list.get(21)==null?null:list.get(21).toString());
				overdueReportPO.setUser_bill_relation(list.get(22)==null?null:list.get(22).toString());
				overdueReportPO.setIs_lock("N");
				overdueReportPO.setCreate_user(user.getCname());
				overdueReportPO.setCreate_date(new Date());
				overdueReportPO.setUpdate_user(user.getCname());
				overdueReportPO.setUpdate_date(new Date());
				overdueReportPO.setConfirm_user(user.getCname());
				overdueReportPO.setConfirm_date(new Date());
				baseDao.saveEntity(overdueReportPO);
			}
		}else{
			log.error("导入的数据为空，事务回滚");
			throw new RuntimeException("导入的数据为空，请重新导入！");
		}
	   return results;
	}



	@Override
	public PageResult<Object[]> getRewardSalaryCheck(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.getRewardSalaryCheck")); 
		
		querySql.append(" AND t.t_month = ?");
		sqlPageQuery.addParam(entity.getMonth());
		
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}



	@Override
	public PageResult<Object[]> downloadRewardSalaryCheck(OverdualForm entity) {
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.downloadRewardSalaryCheck")); 
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}
	
	
	@Override
	public PageResult<Object[]> evaluateLoanDay(OverdualForm entity){
		SqlPageQuery<Object[]> sqlPageQuery = new SqlPageQuery<>(Object[].class, entity.getPageSize(), entity.getPageIndex());
		StringBuffer querySql = new StringBuffer();
		querySql.append(baseDao.getSql("sql.OverdualReportServiceImpl.evaluateLoanDay")); 
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND t.loan_date >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND t.loan_date <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}
		querySql.append(" group by  t.province_code) b on a.province_name = b.province_name) t1 cross join "
				+ "(select sum(s.loan_days)/count(s.loan_days) group_total  from dm_evaluate_loan_day_report s  where 1=1 ");
		if(!StringUtil.isEmpty(entity.getOverDateS())){
			querySql.append(" AND s.loan_date >= ?");
			sqlPageQuery.addParam(entity.getOverDateS());
		}
		if(!StringUtil.isEmpty(entity.getOverDateE())){
			querySql.append(" AND s.loan_date <= ?");
			sqlPageQuery.addParam(entity.getOverDateE());
		}	
	    querySql.append(" ) t2 where 1=1 and t1.province_name not in ('粤东','粤西','浙江','总部')   ");
		if(!StringUtil.isEmpty(entity.getProvince())){
			querySql.append(" AND t1.province_name = ?");
			sqlPageQuery.addParam(entity.getProvince());
		}
		sqlPageQuery.setQuerySql(querySql.toString());
		return baseDao.findDataWithPage(sqlPageQuery);
	}
	
	
	
	
}
